package cn.edu.cqut.mdm.core.publish.local;

import cn.edu.cqut.mdm.container.LocalDefinedModuleContainer;
import cn.edu.cqut.mdm.core.module.ModuleEntity;
import cn.edu.cqut.mdm.core.module.PublishStatus.Status;
import cn.edu.cqut.mdm.core.publish.Publisher;
import cn.edu.cqut.mdm.core.publisherdispatcher.LocalPublisherDispatcher;
import cn.edu.cqut.mdm.register.LocalRegister;

public class LocalPublisher implements Publisher{
	@Override
	public void publish(ModuleEntity module) {
		module.getPublishStatus(new LocalPublisherDispatcher().getName()).setStatus(Status.PUBLISHED);
		LocalRegister.getRegister().register(module);
	}

	@Override
	public void unpublish(String moduleUid) {
		LocalDefinedModuleContainer.getInstance().getModule(moduleUid).getPublishStatus(new LocalPublisherDispatcher().getName()).setStatus(Status.UNPUBLISHED);
		LocalRegister.getRegister().unregister(moduleUid);
	}

}
